package web

import (
	"bili-server/app/entity"
	"github.com/gin-gonic/gin"
)

type Video struct{}

// List
// @Summary 	视频列表
// @Description 视频列表
// @Tags 		videos
// @Accept  	json
// @Produce 	json
// @Success		0 {string}	Response "获取成功"
// @Router 		/videos	[GET]
func (v *Video) List(ctx *gin.Context) {
	Success(ctx, "获取视频列表", entity.GetVideos())
}

// DanMu 获取弹幕
func (v *Video) DanMu(ctx *gin.Context) {
	id := ctx.Param("id")
	if info, ok := entity.MapVideos[id]; ok {
		list, err := entity.GetDanMus(info.Aid)
		if err != nil {
			Failure(ctx, "", err)
			return
		}
		Success(ctx, list)
		return
	}
	Failure(ctx, "未知视频")
}

// Info 获取视频信息
func (v *Video) Info(ctx *gin.Context) {
	id := ctx.Param("id")
	if info, ok := entity.MapVideos[id]; ok {
		Success(ctx, info)
		return
	}
	Failure(ctx, "未知视频")
}
